home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
111_01
/
mcroang.c
< prev
next >
Wrap
Text File
|
1985-08-19
|
11KB
|
593 lines
/*
HEADER: ;
TITLE: MicroAngelo;
VERSION: 1.0;
DATE: 02/28/1982;
DESCRIPTION: "Creates new character sets for the MicroAngelo graphics
board. Compilation requires MCROANG.H.";
KEYWORDS: MicroAngelo, graphics;
SYSTEM: CP/M-80;
FILENAME: MCROANG.C;
SEE-ALSO: MCROANG.H;
AUTHORS: Joe Shannon;
COMPILERS: BDS C;
*/
/***********************************************************************
Version 1.0, 2/28/1982:
This program is released to public domain with the
request that author credit be retained in the source.
Joe Shannon, 566 Rock Road, State College, PA 16801
(814) 238-0029
***********************************************************************/
#include <BDSCIO.H>
#include "MCROANG.H"
#define MBASX 290
#define MBASY 60
#define ABASEC 17
#define ABASER 8
#define FNC 38
#define FNR 50
#define PROMPTC 38
#define PROMPTR 0
#define ON 0
#define OFF 1
#define COMP 2
#define MWIDTH 120
#define MHIGTH 240
#define ALPHABAS 0xF940
#define NOBYTS 1536
main()
{
chrset();
}
chrset()
{
clear();
setac(0,0);
printf("\t\t\t");
alphmode(AMOD_UL);
printf("Modify Alternate Character Set\n");
alphmode(0);
printf("\n\n\tCommand Set\t\t\t\t Motion Commands\n\n");
printf("F- Set File Name for I/O\t\t\t\t7 8 9\n");
printf("L- Load File to MicroAngelo\t\t\t\t \\|/\n");
printf("S- Save File from MicroAngelo\t\t\t\t4 - - 6\n");
printf("A- ASCII Character to work on\t\t\t\t /|\\\n");
printf("E- Exit function\t\t\t\t\t1 2 3\n");
printf("C- Clear the Character\t\t\t\t 5 = Compliment Point\n");
printf("D- Default Char Set (PAC II only)\n");
setac(ABASEC-1,ABASER);
printf(" HIGH BYTE");
setac(ABASEC,ABASER);
alphmode(AMOD_UL);
printf(" 0 1 2 3 4 5 6 7");
alphmode(AMOD_CU);
setac(ABASEC+1,ABASER);
printf("0|");
setac(ABASEC+2,ABASER);
printf("1|");
setac(ABASEC+3,ABASER);
printf("2|");
setac(ABASEC+4,ABASER);
printf("3|");
setac(ABASEC+5,ABASER);
printf("4|");
setac(ABASEC+6,ABASER);
printf("5|");
setac(ABASEC+7,ABASER);
printf("6|");
setac(ABASEC+8,ABASER);
printf("7|");
setac(ABASEC+9,ABASER);
printf("8|");
setac(ABASEC+10,ABASER);
printf("9|");
setac(ABASEC+11,ABASER);
printf("A|");
setac(ABASEC+12,ABASER);
printf("B|");
setac(ABASEC+13,ABASER);
printf("C|");
setac(ABASEC+14,ABASER);
printf("D|");
setac(ABASEC+15,ABASER);
printf("E|");
setac(ABASEC+16,ABASER);
printf("F|");
drwadisp(); /* Display the alternate char set */
setac(FNC,FNR);
printf("FILENAME :-");
/* outline chart */
nvector(ON,MBASX-1,MBASY-1,MBASX+121,MBASY-1);
vector(ON,MBASX+121,MBASY+241);
vector(ON,MBASX-1,MBASY+241);
vector(ON,MBASX-1,MBASY-1);
modify();
alphmode(0);
}
/* main program loop */
modify()
{
char filnam[13];
strcpy(filnam," ");
char c,chr;
int curx,cury;
chr=curx=cury=0;
pltdbl(chr); /* display the char double size */
loadchr(chr); /* get the char from M/A and display it */
togcur(curx,cury); /* turn on cursor */
while((c=tolower(bios(3)))!='e')
switch(c) {
case 'f':
getnam(filnam);
break;
case 'l':
lodfil(filnam);
togcur(curx,cury); /* turn on cursor */
drwadisp(); /* Display the alternate char set */
pltdbl(chr); /* display the char double size */
loadchr(chr); /* get the char from M/A and display it */
togcur(curx,cury); /* turn on cursor */
break;
case 's':
savfil(filnam);
break;
case 'a':
togcur(curx,cury);
chr=asciichr();
togcur(curx,cury);
break;
case 'c':
togcur(curx,cury);
clrchr(chr);
togcur(curx,cury);
break;
case 'd':
togcur(curx,cury);
send8(0x9B);
drwadisp();
pltdbl(chr);
loadchr(chr);
togcur(curx,cury);
break;
case '1':
togcur(curx,cury);
if(cury>0) cury--;
if(curx>0) curx--;
togcur(curx,cury);
break;
case '2':
togcur(curx,cury);
if(cury>0) cury--;
togcur(curx,cury);
break;
case '3':
togcur(curx,cury);
if(curx<5) curx++;
if(cury>0) cury--;
togcur(curx,cury);
break;
case '4':
togcur(curx,cury);
if(curx>0) curx--;
togcur(curx,cury);
break;
case '5':
togcur(curx,cury);
compl(chr,curx,cury);
togcur(curx,cury);
break;
case '6':
togcur(curx,cury);
if(curx<5) curx++;
togcur(curx,cury);
break;
case '7':
togcur(curx,cury);
if(cury<11) cury++;
if(curx>0) curx--;
togcur(curx,cury);
break;
case '8':
togcur(curx,cury);
if(cury<11) cury++;
togcur(curx,cury);
break;
case '9':
togcur(curx,cury);
if(cury<11) cury++;
if(curx<5) curx++;
togcur(curx,cury);
break;
default:
break;
}
}
/* draw the alternate alpha set */
drwadisp()
{
int c,r;
for(c=0;c<16;c++){
for(r=0;r<8;r++){
setac(ABASEC+c+1,ABASER+3+(2*r));
plotachr((r*16)+c);
}
}
}
/* plot alternate char at the current alpha position */
plotachr(c)
char c;
{
send8(CHAR_MOD);
send8(0x80);
send8(GCUR_ALP);
send8(CHAR_PLT);
send8(c);
}
/* plot the char at the double size position */
pltdbl(c)
char c;
{
setgc(MBASX+56,MBASY+250);
send8(CHAR_MOD);
send8(0x84);
send8(CHAR_PLT);
send8(c);
send8(CHAR_MOD);
send8(0);
setac(36,50);
printf("ASCII - %02x",c);
}
getbyt(chr,yloc)
int yloc;
char chr;
{
int add;
add=(ALPHABAS+(chr*12)+(11-yloc));
send8(MEMY_EXM);
send16(1);
send16(add);
return(get8());
}
depbyt(b,chr,yloc)
int b,yloc;
char chr;
{
int add;
add=(ALPHABAS+(chr*12)+(11-yloc));
send8(MEMY_DEP);
send16(1);
send16(add);
send8(b);
}
/* gets a charactor from MicroAngelo & draw matrix */
loadchr(c)
char c;
{
int add,i;
region(OFF,MBASX,MBASY,MBASX+MWIDTH,MBASY+MHIGTH);
for(i=0;i<12;i++) loadbyt(c,i);
}
/* draws one byte of the matrix */
loadbyt(chr,i)
int i;
char chr;
{
char bit;
int j,k;
k=getbyt(chr,i);
bit=32;
for(j=0;j<6;j++){
if( k & bit) markcmp(j,i);
bit=bit>>1;
}
}
/* compliments the mark defined by base coordinates y=0-11 x=0-7 */
markcmp(x,y)
int x,y;
{
int baddx,baddy;
baddy=(y*20)+MBASY+2;
baddx=(x*20)+MBASX+2;
region(COMP,baddx,baddy,baddx+16,baddy+16);
}
/* clear a whole char for fresh start */
clrchr(chr)
char chr;
{
int i;
for(i=0;i<12;i++) depbyt(0,chr,i);
pltdbl(chr);
loadchr(chr);
setac(ABASEC+1+(chr%16),ABASER+3+(2*(chr/16)));
plotachr(chr);
}
/* toggle the graphic cursor ON/OFF */
togcur(curx,cury)
int curx,cury;
{
int addrx,addry;
addrx=MBASX+(curx*20);
addry=MBASY+(cury*20);
nvector(COMP,addrx,addry+10,addrx+20,addry+10);
nvector(COMP,addrx+10,addry,addrx+10,addry+20);
}
/* compliment the grafic loc and adjust the rest */
compl(chr,curx,cury)
int curx,cury;
char chr;
{
char byt,mask;
markcmp(curx,cury);
byt=getbyt(chr,cury);
byt^=(32>>curx);
depbyt(byt,chr,cury);
pltdbl(chr);
setac(ABASEC+1+(chr%16),ABASER+3+(2*(chr/16)));
plotachr(chr);
}
prompt(frmt)
{
clrprompt();
printf("\7\7\7");
setac(PROMPTC,PROMPTR);
printf(frmt);
}
getnam(fnam)
char *fnam;
{
int i;
char *ptr;
ptr=fnam;
prompt("Enter File Name - ********");
setac(PROMPTC,18);
for(i=0;i<8;i++) if((*ptr++=toupper(getchar()))== '\n') break;
*--ptr= 0;
strcat(fnam,".CHR");
clrprompt();
setac(FNC,FNR+13);
printf(" ");
setac(FNC,FNR+13);
printf("%8s",fnam);
printf(" ");
}
asciichr()
{
char chr,ch,cl;
while(1){
prompt("Enter new character in HEX - **");
setac(PROMPTC,29);
if(ishexlo(tolower(ch=getchar())))
if(ishex(tolower(cl=getchar()))) break;
}
ch=htodec(ch);
cl=htodec(cl);
chr=(ch*16)+cl;
pltdbl(chr);
loadchr(chr);
clrprompt();
return(chr);
}
clrprompt()
{
setac(PROMPTC,PROMPTR);
printf(" ");
}
ishex(c)
char c;
{ if(isdigit(c)) return(1);
if((c<'a')||(c>'f')) return(0);
return(1);
}
ishexlo(c)
char c;
{ if(isdigit(c)) if(c<'8') return(1);
return(0);
}
htodec(c)
char c;
{
if(isdigit(c)) return(c-'0');
if(isal